PYTHON-5846 Consolidate CMAP, heartbeat, and SDAM telemetry into _telemetry.py - #14
Closed
blink1073 wants to merge 9 commits into
Closed
PYTHON-5846 Consolidate CMAP, heartbeat, and SDAM telemetry into _telemetry.py#14blink1073 wants to merge 9 commits into
blink1073 wants to merge 9 commits into
Conversation
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Co-authored-by: Steven Silvester <steve.silvester@mongodb.com> Co-authored-by: Noah Stapp <noah@noahstapp.com>
…ongodb#2884) Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Iris <58442094+sleepyStick@users.noreply.github.com>
Co-authored-by: Cloud User <ec2-user@ip-10-128-193-139.ec2.internal> Co-authored-by: Iris <58442094+sleepyStick@users.noreply.github.com> Co-authored-by: Iris <iris.ho@mongodb.com>
Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
…emetry.py Add _CmapTelemetry, _HeartbeatTelemetry, and _SdamTelemetry classes to eliminate the repetitive if-enabled_for_cmap / if-logger.isEnabledFor boilerplate spread across pool.py, monitor.py, topology.py, and server.py.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
[PYTHON-5846]
Changes in this PR
Building on PYTHON-5745 (which consolidated command telemetry), this PR adds three new classes to
pymongo/_telemetry.pyto eliminate the repetitiveif enabled_for_cmap / if _LOGGER.isEnabledFor(logging.DEBUG)boilerplate that was duplicated acrosspool.py,monitor.py,topology.py, andserver.py._CmapTelemetry: Handles all 11 CMAP events (pool created/ready/cleared/closed, connection created/ready/closed, checkout started/succeeded/failed, checked-in). Stored onPooland shared withAsyncConnection. Replacesenabled_for_cmap,enabled_for_logging, and repeated_client_idlog fields._HeartbeatTelemetry: Handles the 3 heartbeat lifecycle events. Usesapm_started()before connection checkout (no conn_id yet) andlog_started()after checkout. Stored asself._current_hbonMonitorto bridge the_check_once/_check_serversplit._SdamTelemetry: Handles topology and server events with queue-based APM publishing. Used byTopology(topology opened/closed/description changed, server opened/closed/description changed) andServer(server closed).Net change: -404 lines across 9 files (async + sync via synchro).
Test Plan
just typing-mypypasses with no issues across all 3 mypy invocations (153, 242, and 2 source files).ruff checkpasses on all changed files.Checklist
Checklist for Author